public class code1 {
    //逆转链表
    //双指针迭代
    public ListNode reverseList(ListNode head) {
        ListNode prev = null;
        ListNode cur = head;
        ListNode tmp = null;//记录cur的位置
        while(cur!=null) {
            tmp = cur.next;//得在最前面
            cur.next = prev;
            prev = cur;
            cur = tmp;
        }
        return prev;


    }
}
